package com.only4play.importapt.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.only4play.importapt.model.entity.CustomerEntity;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public interface CustomerService extends IService<CustomerEntity> {

    default <S> void invokeAll(
        List<List<S>> collections,
        Consumer<List<S>> consumer,
        ExecutorService executorService
    ) throws Exception {
        List<Callable<Void>> callables = collections.stream()
            .map(item -> (Callable<Void>) () -> {
                consumer.accept(item);
                return null;
            })
            .collect(Collectors.toList());
        executorService.invokeAll(callables);
    }

//    Map<String, CustomerEntity> qryByIds(List<WrapRequest> requests);

//    Boolean insertByThreadPool(CustomerEntity entity);
}
